Add interpreter support for unit natives - #1279
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fe35b24b0d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2327201f5c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 86f36e291e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e629acb0cc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8d741520a4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4d20d35ccc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 08ed57c71f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4da148417b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7a15c9c085
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| public ILconstBool IsUnitIdType(ILconstInt unitId, IlConstHandle unitType) { | ||
| return IsHeroUnitId(unitId); |
There was a problem hiding this comment.
Inspect the requested type in IsUnitIdType
Fresh evidence in the final tree is that unitType is never inspected: IsUnitIdType('Hpal', UNIT_TYPE_DEAD) and IsUnitIdType('Hpal', UNIT_TYPE_STRUCTURE) both return true, while non-hero IDs return false even for their matching classifications. Restrict the hero heuristic to UNIT_TYPE_HERO and classify other requested types separately.
Useful? React with 👍 / 👎.
| public void SetHeroXP(IlConstHandle unit, ILconstInt xp, ILconstBool showEyeCandy) { | ||
| UnitMock unitMock = unitOrNull(unit); | ||
| if (unitMock != null) unitMock.heroXp = xp; |
There was a problem hiding this comment.
Keep hero XP and level in sync
When SetHeroXP or AddHeroXP crosses a level threshold, only heroXp changes, so GetHeroLevel continues returning the old level and no corresponding skill points are awarded. Interpreted hero-progression logic can therefore observe an impossible XP/level combination; update the derived level and skill-point state when XP changes.
Useful? React with 👍 / 👎.
| public ILconstInt IncUnitAbilityLevel(IlConstHandle unit, ILconstInt abilityId) { | ||
| return SetUnitAbilityLevel(unit, abilityId, ILconstInt.create(GetUnitAbilityLevel(unit, abilityId).getVal() + 1)); |
There was a problem hiding this comment.
Refuse increments for abilities the unit does not have
When IncUnitAbilityLevel is called for an absent ability, GetUnitAbilityLevel supplies zero and the delegated setter inserts the ability at level 1. This makes a level-changing native silently grant an ability and even causes the subsequent presence check in UnitMakeAbilityPermanent to succeed; return zero without mutating state unless the ability is already present.
Useful? React with 👍 / 👎.
Summary
UnitMakeAbilityPermanentandIsUnitHidden/ShowUnit.common.jUnit API, including creation, movement, ownership, hero state, inventory, orders, resources, sleep, damage, and waygate helpers.Checks
./gradlew test --tests tests.wurstscript.tests.InterpreterTests -x versionInfoFile— passed.git diff --check— passed.The repository's
versionInfoFiletask assumes.gitis a directory and fails validation in a Git worktree, so the focused test run excludes that task and uses a temporary generated version-info file in the isolated worktree only.